package com.shy.collect.controller;

import com.shy.configs.mvc.models.PageObject;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 封装分页参数
 */
public class BaseController {

    protected Integer defPageNo(Integer pageNo) {
        Integer pageNum = pageNo;
        if (pageNum == null || pageNum < 1) {
            pageNum = 1;
        }
        return pageNum;
    }

    protected Integer defPageSze(Integer pageSize) {
        Integer size = pageSize;
        if (size == null) {
            size = 10;
        }
        return size;
    }


    protected static Map<String, Object> wrapData(List<?> listData, PageObject pageObject) {
        Map<String, Object> data = new HashMap<>();
        data.put("list", listData);
        data.put("page", pageObject);
        return data;
    }
}